package controllers.admin;

import models.admin.Permission;
import play.mvc.With;
import controllers.BaseController;
import controllers.Check;
import controllers.Secure;

/**
 * @author rjanixz
 *
 * Controller for Permissions page
 */
@With(Secure.class)
public class Permissions extends BaseController {

	@Check(value = "ADD")
	public static void save(String name, String description) {
		Permission permission = new Permission();
		permission.setName(name);
		permission.setDescription(description);
		permission.save();
		redirect("/admin/permissions/all");
	}
	
	@Check(value = "EDIT")
	public static void update(Long permissionId, String name, String description) {
		Permission permission = Permission.findById(permissionId);
		permission.setName(name);
		permission.setDescription(description);
		permission.save();
		redirect("/admin/permissions/all");
	}
}
